<?php
	include("../session_ini.php");
	
	include_once("../model/utils/Thumb.php");
		
	//mueve el archivo a un directorio
	$directorio = '../view/uploads/logos/'.$_FILES['fileToUpload']['name'];
	
	move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $directorio);
	
	$mythumb = new Thumb();  
	$mythumb->loadImage($directorio);
	list($width, $height, $type, $attr) = getimagesize($directorio);
	if($width > $height){
		$mythumb->resize(100, 'height');
	}else{
		$mythumb->resize(100, 'width');
	}
	$mythumb->crop(100, 100, 'center');
	
	$directorio2 = 'uploads/logos/'.md5(mt_rand(00000000, 99999999)).'.jpg';
	
	$mythumb->save("../view/".$directorio2, 100);
	
	echo URL_BASE()."/view/$directorio2";
	
	//for security reason, we force to remove all uploaded file
	@unlink($_FILES['fileToUpload']);
	//unlink($directorio);
	
?>